package com.meichis.yndms.repository;

import android.util.ArrayMap;

import com.google.gson.Gson;
import com.meichis.mcsappframework.BaseApplication;
import com.meichis.mcsappframework.utils.SharePreferenceUtil;
import com.meichis.mcsappframework.utils.Tools;
import com.meichis.yndms.model.WSIRequestPack;

import java.util.UUID;

public class ApiUtil {

    public static WSIRequestPack getRequestPack(String ParamsStr)
    {
        WSIRequestPack requestPack = new WSIRequestPack();
        requestPack.setMessageId(UUID.randomUUID().toString());
        SharePreferenceUtil util = SharePreferenceUtil.getInstance();
        requestPack.setParams(ParamsStr);
        requestPack.setDeviceCode(Tools.getDeviceId(BaseApplication.getContext()));
        return  requestPack;
    }

    public static WSIRequestPack getRequestPack(Object Params)
    {
        WSIRequestPack requestPack = new WSIRequestPack();
        requestPack.setMessageId(UUID.randomUUID().toString());
        requestPack.setParams(new Gson().toJson(Params));
        requestPack.setDeviceCode(Tools.getDeviceId(BaseApplication.getContext()));
        return  requestPack;
    }

    public static WSIRequestPack getRequestPack(Object Params, String serviceCode) {
        ArrayMap<String, Object> hs = new ArrayMap<>();
        //MDS经销商ID
        hs.put("Params", new Gson().toJson(Params));
        hs.put("ServiceCode", serviceCode);
        WSIRequestPack requestPack = new WSIRequestPack();
        requestPack.setMessageId(UUID.randomUUID().toString());
        requestPack.setParams(new Gson().toJson(hs));
        requestPack.setDeviceCode(Tools.getDeviceId(BaseApplication.getContext()));
        return requestPack;
    }

    public static WSIRequestPack getRequestPack(int sequence,Object Params, String serviceCode) {
        ArrayMap<String, Object> hs = new ArrayMap<>();
        //MDS经销商ID
        hs.put("Params", new Gson().toJson(Params));
        hs.put("ServiceCode", serviceCode);
        WSIRequestPack requestPack = new WSIRequestPack();
        requestPack.setSequence(sequence);
        requestPack.setMessageId(UUID.randomUUID().toString());
        requestPack.setParams(new Gson().toJson(hs));
        requestPack.setDeviceCode(Tools.getDeviceId(BaseApplication.getContext()));
        return requestPack;
    }
}
